import 'package:flutter/material.dart';
import '../Constants/constants.dart' show AppColors;
import '../Constants/constants.dart';
import '../Constants/styles/app_style.dart';

class FullFunIconBtn extends StatelessWidget {
  final String iconPath;
  final String title;
  final bool hasDivider;
  final bool hasPic;
  final VoidCallback pressed;
  List<Widget> _layouts;
  List<Widget> _layoutsRow;

  FullFunIconBtn(
      {@required this.iconPath,
      @required this.title,
      //@required this.hasBottom,
      this.hasDivider: false,
      this.hasPic:true,
      @required this.pressed});

  @override
  Widget build(BuildContext context) {
    _layoutsRow = [
              SizedBox(width:Constants.Wh * 50),
              Image.asset(this.iconPath,
                  width: Constants.Wh * 72, height: Constants.Wh * 72),
                  SizedBox(width:Constants.Wh * 38),
              Container(
                child: Text(this.title,
                    style:TextStyleNw.listItemMain,)
              ),
              Expanded(flex: 1,child: Container(),),
              Container(
                  width: Constants.Wh * 20,
                  height: Constants.Hh*36,
                  margin:EdgeInsets.only(right:Constants.Wh * 44),
              child:Image.asset('assets/images/ima_right_arrow.png',fit: BoxFit.fill,))
              //Container(width: 45,height:20,color: Colors.red,),
    ];
    if(this.hasPic == false){
_layoutsRow.removeAt(0);
_layoutsRow.removeAt(0);
_layoutsRow.removeAt(0);
_layoutsRow.insert(0,SizedBox(width:Constants.Wh * 46));
    }
    _layouts = [
      Container(         
          padding: EdgeInsets.only(top: Constants.Hh * 42, bottom: Constants.Hh * 42),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: _layoutsRow
          ))
    ];
 
    //如果带下划线
    if (this.hasDivider == true) {
         _layouts.add(Container(
        color:Color(AppColors.WhiteColor),
       padding:EdgeInsets.only(left:50),
      child: Divider(height: 1,color: Color(AppColors.SpliteLineColor),),
       ));
    }
    return FlatButton (
      padding: EdgeInsets.only(left:0),
      shape: RoundedRectangleBorder(
           side: BorderSide(width: 0, color: Colors.transparent)),

      color:Colors.white,
      onPressed: this.pressed,
      child: Column(
          crossAxisAlignment: CrossAxisAlignment.start, children: _layouts),
    );
  }
}
